#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int M=1e6+5;
#define ls(p) p<<1
#define rs(p) p<<1|1
int t,n,m,L,V;
int d[N],v[N],a[N],p[N],ans,del;
struct node{
    int l,r;
    bool operator <(const node& y)const{
        if(l==y.l)
            return r<y.r;
        return l<y.l;
    }
}car[N];
struct po{
    int x,ltr;
    bool operator <(const po& y)const{
        return x<y.x;
    }
}pos[N<<1];
int tr[M<<2];
void build(int p,int l,int r){
    tr[p]=0;
    if(l==r)
        return;
    int mid=(l+r)>>1;
    build(ls(p),l,mid);
    build(rs(p),mid+1,r);
}
void add(int p,int l,int r,int x,int v){
    if(l==r){
        tr[p]+=v;
        return;
    }
    int mid=(l+r)>>1;
    if(x<=mid)
        add(ls(p),l,mid,x,v);
    else
        add(rs(p),mid+1,r,x,v);
    tr[p]=tr[ls(p)]+tr[rs(p)];
}
int getnum(int p,int l,int r,int x,int y){
    if(x<=l&&r<=y)
        return tr[p];
    int mid=(l+r)>>1,ans=0;
    if(x<=mid)
        ans+=getnum(ls(p),l,mid,x,y);
    if(y>mid)
        ans+=getnum(rs(p),mid+1,r,x,y);
    return ans;
}
void dfs(int x,int sum){
    if(x>m){
        if(del>=sum)  return;
        int tmp=0;
        for(int i=1;i<=n;i++){
            if(car[i].l==-1||car[i].r==-1)  continue;
            if(getnum(1,1,L,car[i].l,car[i].r)>0)
                tmp++;
        }
        if(tmp==ans)
            del=sum;
        return;
    }
    add(1,1,L,p[x],-1);
    dfs(x+1,sum+1);
    add(1,1,L,p[x],1);
    dfs(x+1,sum);
}
/*void tmp(){
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(car[i].l==-1||car[i].r==-1)  continue;
        pos[++cnt]={car[i].l,1};
        pos[++cnt]={car[i].r,-1};
    }
    sort(pos+1,pos+1+cnt);
    int delt=0,cntl=1;
    for(int i=1;i<=m&&cntl<=cnt;i++){
        bool f=0,t=0;
        for(;cntl<=cnt&&pos[cntl].x<=p[i];cntl++){
            if(pos[cntl].x<p[i]&&pos[cntl].ltr==-1)
                f=1;
            if(pos[cntl].ltr==1)
                t=1;
        }
        if(f&&t)  continue;
        delt++;
    }
    del=delt;
}*/
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        ans=0;
        cin>>n>>m>>L>>V;
        L++;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            d[i]++;
            if(v[i]>V&&a[i]>=0){
                car[i].l=d[i];
                car[i].r=L;
            }
            else if(v[i]<=V&&a[i]<=0){
                car[i].l=car[i].r=-1;
            }
            else if(v[i]>V){
                car[i].l=d[i];
                car[i].r=min(L,d[i]+(V*V-v[i]*v[i])/2/a[i]);
            }
            else if(v[i]<=V){
                car[i].r=L;
                int tmp=d[i]+(V*V-v[i]*v[i])/2/a[i];
                if(tmp>L)
                    car[i].l=car[i].r=-1;
                else
                    car[i].l=tmp;
            }
        }
        build(1,1,L);
        for(int i=1;i<=m;i++){
            cin>>p[i];
            p[i]++;
            add(1,1,L,p[i],1);
        }
        for(int i=1;i<=n;i++){
            if(car[i].l>car[i].r)
                car[i].l=car[i].r=-1;
            if(car[i].l==-1||car[i].r==-1)  continue;
            if(getnum(1,1,L,car[i].l,car[i].r)>0)
                ans++;
            else
                car[i].l=car[i].r=-1;
        }
        cout<<ans<<" ";
        del=0;
        //tmp();
        dfs(1,0);
        cout<<del<<"\n";
    }
    return 0;
}
